package com.gulimall.search.controller;

import com.gulimall.common.core.domain.Result;
import com.gulimall.common.vo.search.SearchParam;
import com.gulimall.common.vo.search.SearchResult;
import com.gulimall.search.service.MallSearchService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.io.IOException;

@Slf4j
@RestController
public class SearchController {
    @Resource
    private MallSearchService mallSearchService;

    /**
     * 商品搜索功能
     */
    @GetMapping("/list.html")
    public Result listPage(SearchParam param) throws IOException {
        log.info("搜索查询：");
        SearchResult result = mallSearchService.search(param);
        return Result.ok(result);
    }
}
